package com.yxhl.zoume.domain.interactor.car.expresscar;

import com.google.protobuf.GeneratedMessageV3;
import com.yxhl.protobuf.BizOrderRequest;
import com.yxhl.protobuf.BizOrderResponse;
import com.yxhl.zoume.data.http.repository.car.ExpressCarRepository;
import com.yxhl.zoume.domain.DomainConstants;
import com.yxhl.zoume.domain.interactor.base.ProtoUseCase;

import javax.inject.Inject;
import javax.inject.Named;

import rx.Observable;
import rx.Scheduler;

/**
 * Author：zhongshan   
 * Date：2016/12/14 18:48      
 * Description：专车－下单
 */
public class CreateExpressCarOrderUseCase extends ProtoUseCase<BizOrderResponse> {
    private ExpressCarRepository expressCarRepository;

    @Inject
    public CreateExpressCarOrderUseCase(@Named(DomainConstants.UI_THREAD) Scheduler uiThread,
                                        @Named(DomainConstants.EXECUTOR_THREAD) Scheduler executorThread,
                                        ExpressCarRepository expressCarRepository) {
        super(uiThread, executorThread);
        this.expressCarRepository = expressCarRepository;
    }

    @Override
    protected Observable<BizOrderResponse> buildObservable(GeneratedMessageV3 message) {
        return expressCarRepository
                .createExpressCarOrder((BizOrderRequest) message)
                .subscribeOn(executorThread)
                .observeOn(uiThread);
    }
}
